package com.headfirst.ooad;

import java.util.Iterator;
import java.util.List;

import org.junit.Test;

import junit.framework.TestCase;

import com.headfirst.ooad.GuitarSpec.Builder;
import com.headfirst.ooad.GuitarSpec.Type;
import com.headfirst.ooad.GuitarSpec.Wood;

import junit.framework.Assert.*;

public class FindGuitarTester extends TestCase{
	
	Inventory inventory = new Inventory();
	
	@Test
	public void testFind() {
		
		GuitarSpec whatErinLikes = new GuitarSpec(Builder.FENDER,
				"Stratocastor", Type.ELECTRIC, Wood.ALDER, Wood.ALDER);
		
		List<Guitar> matchingGuitars = inventory.search(whatErinLikes);
		if (!matchingGuitars.isEmpty()) {
			System.out.println("Erin, you might like these guitars:");
			for (Iterator<Guitar> i = matchingGuitars.iterator(); i.hasNext();) {
				Guitar guitar = (Guitar) i.next();
				GuitarSpec spec = guitar.getSpec();
				System.out.println(" We have a " + spec.getBuilder() + " "
						+ spec.getModel() + " " + spec.getType()
						+ " guitar:\n " + spec.getBackWood()
						+ " back and sides,\n " + spec.getTopWood()
						+ " top.\n You can have it for only $"
						+ guitar.getPrice() + "!\n ----");
			}
		} else {
			System.out.println("Sorry, Erin, we have nothing for you.");
			fail();
		}
	}

	@org.junit.After
	public void setUp() {
	}
}
